package com.dhf.framework.system.service;


import java.math.BigInteger;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.dhf.framework.base.mybatis.core.dao.GenericDao;
import com.dhf.framework.base.mybatis.core.service.GenericService;
import com.dhf.framework.base.utils.Coder;
import com.dhf.framework.system.dao.SysUserDao;
import com.dhf.framework.system.entity.SysUser;

/**
 * 描述：</b>SysUserService<br>
 * @author：HoraceHo
 * @since：2016年06月17日 17时01分51秒 星期五 
 * @version:1.0
 */
@Service
public class SysUserService extends GenericService<SysUser,Long>{
	
	public final Logger    logger  = LoggerFactory.getLogger( this.getClass() );

	@Autowired
	private SysUserDao sysUserDao;

    
    @Override
    public GenericDao<SysUser, Long> getMyBatisGenericDao() {
        return sysUserDao;
    }
    
    public Boolean login(SysUser sysUser) throws Exception{
        String password=new BigInteger(Coder.encryptHMAC(sysUser.getPassword().getBytes(), sysUser.getPassword())).toString(16);
        SysUser user= sysUserDao.findUserByName(sysUser.getLoginName());
        if(password.equals(user.getPassword())){
            return true ;
        }else{
            return false ;
        }
    }
}

